CSharpTest.Net
SaltedData Constructor(Byte[])
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > SaltedData Class > SaltedData Constructor : SaltedData Constructor(Byte[])

saltedData

Glossary Item Box

Seperates the salt from the data provided

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal saltedData() As Byte _
)
C# 
public SaltedData( 
   byte[] saltedData
)

Parameters

saltedData

Example

Library/Library.Test/TestSalt.cs

C#Copy Code
Salt s = new Salt();
byte[] testData = new byte[8];
new Random().NextBytes(testData);
byte[] tmp;

using (SaltedData sd = new SaltedData(s, testData))
{
    Assert.AreEqual(40, sd.Length);
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());

    tmp = sd.ToArray();
    Assert.AreEqual(40, tmp.Length);
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()));
}

using (SaltedData sd = new SaltedData(tmp))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}

using (SaltedData sd = new SaltedData(new MemoryStream(tmp)))
{
    Assert.AreEqual(s, sd.Salt);
    Assert.AreEqual(testData, sd.GetDataBytes());
    Assert.AreEqual(tmp, sd.ToArray());
}
VB.NETCopy Code
Dim s As New Salt()
Dim testData As Byte() = New Byte(8) {}
New Random().NextBytes(testData)
Dim tmp As Byte()

Using sd As New SaltedData(s, testData)
    Assert.AreEqual(40, sd.Length)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())

    tmp = sd.ToArray()
    Assert.AreEqual(40, tmp.Length)
    Assert.AreEqual(tmp, IOStream.ReadAllBytes(sd.ToStream()))
End Using

Using sd As New SaltedData(tmp)
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Using sd As New SaltedData(New MemoryStream(tmp))
    Assert.AreEqual(s, sd.Salt)
    Assert.AreEqual(testData, sd.GetDataBytes())
    Assert.AreEqual(tmp, sd.ToArray())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys